/*
 * Copyright 2018 JDCLOUD.COM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http:#www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * 云流水线
 * 云流水线API
 *
 * OpenAPI spec version: v1
 * Contact: 
 *
 * NOTE: This class is auto generated by the jdcloud code generator program.
 */


using JDCloudSDK.Core.Auth;
using JDCloudSDK.Core.Client;
using JDCloudSDK.Core.Http;
using JDCloudSDK.Pipeline.Apis;
using JDCloudSDK.Pipeline.Model;
using System;
using System.Collections.Generic;
using System.Text;
#if NET40||NET35
#else
using System.Threading.Tasks;
#endif

namespace JDCloudSDK.Pipeline.Client
{
    /// <summary>
    ///  云流水线
    ///  云流水线API
    ///  Pipeline Api 客户端
    ///</summary>
    public class PipelineClient : JdcloudClient
    {

        /// <summary>
        ///  默认私有构造函数
        /// </summary>
        private PipelineClient()
        {

        }

        /// <summary>
        /// 默认构造函数
        /// </summary>
        /// <param name="credentialsProvider">认证信息</param>
        /// <param name="httpRequestConfig">http 客户端配置信息</param>
        /// <param name="environment">sdk 环境配置信息</param>
        public PipelineClient(CredentialsProvider credentialsProvider, HttpRequestConfig httpRequestConfig,SDKEnvironment environment)
        {
            this.httpRequestConfig = httpRequestConfig;
            this.credentialsProvider = credentialsProvider;
            this.environment = environment;
        }

        /// <summary>
        /// 默认构造函数
        /// </summary>
        /// <param name="httpRequestConfig">http 客户端配置信息</param>
        /// <param name="credentialsProvider">认证信息</param>
        public PipelineClient(CredentialsProvider credentialsProvider,HttpRequestConfig httpRequestConfig)
        {
            this.httpRequestConfig = httpRequestConfig;
            this.credentialsProvider = credentialsProvider;
        }

        /// <summary>
        /// 默认构造函数，
        /// 注意如果使用此方法 httpRequestConfig 使用的http 请求 schema 为Https
        /// </summary>
        /// <param name="credentialsProvider">认证信息</param>
        public PipelineClient(CredentialsProvider credentialsProvider)
        {
            this.credentialsProvider = credentialsProvider;
        }

        /// <summary>
        ///  版本号 1.1.0
        ///</summary>
        public const string ClientVersion = "1.1.0";

        private const string apiVersion = "v1";
        private const string userAgentPrefix = "JdcloudSdkDotNet";
        private const string defaultEndpoint = "pipeline.jdcloud-api.com";
        private const string serviceName = "pipeline";
        private const string userAgent = userAgentPrefix + "/" + ClientVersion + " " + serviceName + "/" + apiVersion;


        private SDKEnvironment environment = new SDKEnvironment(defaultEndpoint);
        private CredentialsProvider credentialsProvider;
        private HttpRequestConfig httpRequestConfig;

        /// <summary>
        ///  获取证书信息
        ///</summary>
        public override CredentialsProvider CredentialsProvider   { get { return credentialsProvider; } }

        /// <summary>
        ///  获取http 客户端配置信息
        ///</summary>
        public override HttpRequestConfig HttpRequestConfig { get { return httpRequestConfig; } }

        /// <summary>
        ///  获取sdk环境配置信息
        ///</summary>
        public override SDKEnvironment SDKEnvironment { get { return environment; } }

        /// <summary>
        ///  获取用户自定义浏览器识别字符串
        ///</summary>
        public override string UserAgent { get { return userAgent; } }

        /// <summary>
        ///  获取服务名称
        ///</summary>
        public override string ServiceName { get { return serviceName; } }

        /// <summary>
        ///  获取版本号
        ///</summary>
        public override string Version { get { return apiVersion; } }



#if NET40||NET35
        /// <summary>
        ///  查询获取流水线任务列表，并显示最后一次执行的状态或结果信息
        /// /v1/regions/cn-south-1?sorts.1.name&#x3D;startedAt&amp;sorts.1.direction&#x3D;desc&amp;pageNumber&#x3D;1&amp;pageSize&#x3D;10&amp;filters.1.name&#x3D;name&amp;filters.1.values.1&#x3D;我的pipeline
        /// 
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public GetPipelinesResponse GetPipelines(GetPipelinesRequest request) {
            return  new GetPipelinesExecutor().Client(this).Execute<GetPipelinesResponse, GetPipelinesResult, GetPipelinesRequest>(request);
        }
#else
        /// <summary>
        ///  查询获取流水线任务列表，并显示最后一次执行的状态或结果信息
        /// /v1/regions/cn-south-1?sorts.1.name&#x3D;startedAt&amp;sorts.1.direction&#x3D;desc&amp;pageNumber&#x3D;1&amp;pageSize&#x3D;10&amp;filters.1.name&#x3D;name&amp;filters.1.values.1&#x3D;我的pipeline
        /// 
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<GetPipelinesResponse> GetPipelines(GetPipelinesRequest request) {
            return await new GetPipelinesExecutor().Client(this).Execute<GetPipelinesResponse, GetPipelinesResult, GetPipelinesRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  根据uuid启动一个流水线任务
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public StartPipelineResponse StartPipeline(StartPipelineRequest request) {
            return  new StartPipelineExecutor().Client(this).Execute<StartPipelineResponse, StartPipelineResult, StartPipelineRequest>(request);
        }
#else
        /// <summary>
        ///  根据uuid启动一个流水线任务
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<StartPipelineResponse> StartPipeline(StartPipelineRequest request) {
            return await new StartPipelineExecutor().Client(this).Execute<StartPipelineResponse, StartPipelineResult, StartPipelineRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  新建流水线任务
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public CreatePipelineResponse CreatePipeline(CreatePipelineRequest request) {
            return  new CreatePipelineExecutor().Client(this).Execute<CreatePipelineResponse, CreatePipelineResult, CreatePipelineRequest>(request);
        }
#else
        /// <summary>
        ///  新建流水线任务
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<CreatePipelineResponse> CreatePipeline(CreatePipelineRequest request) {
            return await new CreatePipelineExecutor().Client(this).Execute<CreatePipelineResponse, CreatePipelineResult, CreatePipelineRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  更新流水线任务
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public UpdatePipelineResponse UpdatePipeline(UpdatePipelineRequest request) {
            return  new UpdatePipelineExecutor().Client(this).Execute<UpdatePipelineResponse, UpdatePipelineResult, UpdatePipelineRequest>(request);
        }
#else
        /// <summary>
        ///  更新流水线任务
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<UpdatePipelineResponse> UpdatePipeline(UpdatePipelineRequest request) {
            return await new UpdatePipelineExecutor().Client(this).Execute<UpdatePipelineResponse, UpdatePipelineResult, UpdatePipelineRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  上传文件，返回文件内容
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public ReadFileResponse ReadFile(ReadFileRequest request) {
            return  new ReadFileExecutor().Client(this).Execute<ReadFileResponse, ReadFileResult, ReadFileRequest>(request);
        }
#else
        /// <summary>
        ///  上传文件，返回文件内容
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<ReadFileResponse> ReadFile(ReadFileRequest request) {
            return await new ReadFileExecutor().Client(this).Execute<ReadFileResponse, ReadFileResult, ReadFileRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  根据uuid获取流水线任务的配置信息
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public GetPipelineResponse GetPipeline(GetPipelineRequest request) {
            return  new GetPipelineExecutor().Client(this).Execute<GetPipelineResponse, GetPipelineResult, GetPipelineRequest>(request);
        }
#else
        /// <summary>
        ///  根据uuid获取流水线任务的配置信息
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<GetPipelineResponse> GetPipeline(GetPipelineRequest request) {
            return await new GetPipelineExecutor().Client(this).Execute<GetPipelineResponse, GetPipelineResult, GetPipelineRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  查询用户限制
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public GetLimitsResponse GetLimits(GetLimitsRequest request) {
            return  new GetLimitsExecutor().Client(this).Execute<GetLimitsResponse, GetLimitsResult, GetLimitsRequest>(request);
        }
#else
        /// <summary>
        ///  查询用户限制
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<GetLimitsResponse> GetLimits(GetLimitsRequest request) {
            return await new GetLimitsExecutor().Client(this).Execute<GetLimitsResponse, GetLimitsResult, GetLimitsRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  删除一个流水线任务
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public DeletePipelineResponse DeletePipeline(DeletePipelineRequest request) {
            return  new DeletePipelineExecutor().Client(this).Execute<DeletePipelineResponse, DeletePipelineResult, DeletePipelineRequest>(request);
        }
#else
        /// <summary>
        ///  删除一个流水线任务
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<DeletePipelineResponse> DeletePipeline(DeletePipelineRequest request) {
            return await new DeletePipelineExecutor().Client(this).Execute<DeletePipelineResponse, DeletePipelineResult, DeletePipelineRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  查询流水线执行历史列表
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public GetPipelineInstancesResponse GetPipelineInstances(GetPipelineInstancesRequest request) {
            return  new GetPipelineInstancesExecutor().Client(this).Execute<GetPipelineInstancesResponse, GetPipelineInstancesResult, GetPipelineInstancesRequest>(request);
        }
#else
        /// <summary>
        ///  查询流水线执行历史列表
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<GetPipelineInstancesResponse> GetPipelineInstances(GetPipelineInstancesRequest request) {
            return await new GetPipelineInstancesExecutor().Client(this).Execute<GetPipelineInstancesResponse, GetPipelineInstancesResult, GetPipelineInstancesRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  查询多个指定流水线执行及状态信息
        /// 
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public ManualActionResponse ManualAction(ManualActionRequest request) {
            return  new ManualActionExecutor().Client(this).Execute<ManualActionResponse, ManualActionResult, ManualActionRequest>(request);
        }
#else
        /// <summary>
        ///  查询多个指定流水线执行及状态信息
        /// 
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<ManualActionResponse> ManualAction(ManualActionRequest request) {
            return await new ManualActionExecutor().Client(this).Execute<ManualActionResponse, ManualActionResult, ManualActionRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  查询流水线执行结果及状态信息
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public GetPipelineInstanceResponse GetPipelineInstance(GetPipelineInstanceRequest request) {
            return  new GetPipelineInstanceExecutor().Client(this).Execute<GetPipelineInstanceResponse, GetPipelineInstanceResult, GetPipelineInstanceRequest>(request);
        }
#else
        /// <summary>
        ///  查询流水线执行结果及状态信息
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<GetPipelineInstanceResponse> GetPipelineInstance(GetPipelineInstanceRequest request) {
            return await new GetPipelineInstanceExecutor().Client(this).Execute<GetPipelineInstanceResponse, GetPipelineInstanceResult, GetPipelineInstanceRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  停止流水线的一次执行
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public StopPipelineInstanceResponse StopPipelineInstance(StopPipelineInstanceRequest request) {
            return  new StopPipelineInstanceExecutor().Client(this).Execute<StopPipelineInstanceResponse, StopPipelineInstanceResult, StopPipelineInstanceRequest>(request);
        }
#else
        /// <summary>
        ///  停止流水线的一次执行
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<StopPipelineInstanceResponse> StopPipelineInstance(StopPipelineInstanceRequest request) {
            return await new StopPipelineInstanceExecutor().Client(this).Execute<StopPipelineInstanceResponse, StopPipelineInstanceResult, StopPipelineInstanceRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  获取可选的源提供商
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public GetSourceProvidersResponse GetSourceProviders(GetSourceProvidersRequest request) {
            return  new GetSourceProvidersExecutor().Client(this).Execute<GetSourceProvidersResponse, GetSourceProvidersResult, GetSourceProvidersRequest>(request);
        }
#else
        /// <summary>
        ///  获取可选的源提供商
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<GetSourceProvidersResponse> GetSourceProviders(GetSourceProvidersRequest request) {
            return await new GetSourceProvidersExecutor().Client(this).Execute<GetSourceProvidersResponse, GetSourceProvidersResult, GetSourceProvidersRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  操作提供商
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public GetOperationProvidersResponse GetOperationProviders(GetOperationProvidersRequest request) {
            return  new GetOperationProvidersExecutor().Client(this).Execute<GetOperationProvidersResponse, GetOperationProvidersResult, GetOperationProvidersRequest>(request);
        }
#else
        /// <summary>
        ///  操作提供商
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<GetOperationProvidersResponse> GetOperationProviders(GetOperationProvidersRequest request) {
            return await new GetOperationProvidersExecutor().Client(this).Execute<GetOperationProvidersResponse, GetOperationProvidersResult, GetOperationProvidersRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  根据条件查询流水线执行历史
        /// 
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public GetPipelineInstancesByUuidsResponse GetPipelineInstancesByUuids(GetPipelineInstancesByUuidsRequest request) {
            return  new GetPipelineInstancesByUuidsExecutor().Client(this).Execute<GetPipelineInstancesByUuidsResponse, GetPipelineInstancesByUuidsResult, GetPipelineInstancesByUuidsRequest>(request);
        }
#else
        /// <summary>
        ///  根据条件查询流水线执行历史
        /// 
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<GetPipelineInstancesByUuidsResponse> GetPipelineInstancesByUuids(GetPipelineInstancesByUuidsRequest request) {
            return await new GetPipelineInstancesByUuidsExecutor().Client(this).Execute<GetPipelineInstancesByUuidsResponse, GetPipelineInstancesByUuidsResult, GetPipelineInstancesByUuidsRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  可选地域
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public GetRegionsResponse GetRegions(GetRegionsRequest request) {
            return  new GetRegionsExecutor().Client(this).Execute<GetRegionsResponse, GetRegionsResult, GetRegionsRequest>(request);
        }
#else
        /// <summary>
        ///  可选地域
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<GetRegionsResponse> GetRegions(GetRegionsRequest request) {
            return await new GetRegionsExecutor().Client(this).Execute<GetRegionsResponse, GetRegionsResult, GetRegionsRequest>(request).ConfigureAwait(false);
        }
#endif

            /// <summary>
            ///  默认PipelineClient 构造器 接口
            ///</summary>
            public interface Builder
            {

                /// <summary>
                /// 设置认证信息参数
                /// </summary>
                /// <param name="provider">认证信息提供对象</param>
                /// <returns>pipelineClient 构造器</returns>
                Builder CredentialsProvider(CredentialsProvider provider);

                /// <summary>
                /// 设置请求环境参数
                /// </summary>
                /// <param name="environment">环境参数信息</param>
                /// <returns>pipelineClient 构造器</returns>
                Builder Environment(Core.Client.SDKEnvironment environment);

                /// <summary>
                /// http 请求配置信息
                /// </summary>
                /// <param name="config">http 请求配置信息</param>
                /// <returns>pipelineClient 构造器</returns>
                Builder HttpRequestConfig(HttpRequestConfig config);

                /// <summary>
                ///  构造PipelineClient 对象
                ///</summary>
                PipelineClient Build();
            }

            /// <summary>
            ///  默认PipelineClient 构造器
            ///</summary>
            public class DefaultBuilder : Builder
            {
                /// <summary>
                ///  PipelineClient service client
                /// </summary>
                private  PipelineClient pipelineClient;

                /// <summary>
                ///  默认PipelineClient 构造器构造对象
                ///</summary>
                public DefaultBuilder()
                {
                    pipelineClient = new PipelineClient();
                }

                /// <summary>
                ///  构造PipelineClient 对象
                ///</summary>
                public PipelineClient Build()
                {
                    if (pipelineClient.CredentialsProvider == null)
                    {
                        //if credentialsProvider not set, try load jdcloud global default  credentials provider
                        pipelineClient.credentialsProvider = JdCloud.DefaultInstance.GetCredentialsProvider();
                        if (pipelineClient.credentialsProvider == null)
                        {
                            throw new ArgumentNullException("PipelineClient build error: jdcloud credentials provider not set");
                        }
                    }
                    if (pipelineClient.HttpRequestConfig == null)
                    {
                        pipelineClient.httpRequestConfig = JdCloud.DefaultInstance.GetHttpRequestConfig();
                        if (pipelineClient.httpRequestConfig == null)
                        {
                        throw new ArgumentNullException("PipelineClient build error: http request config not set");
                        }
                    }
                    return pipelineClient;
                }

                /// <summary>
                /// 设置认证信息参数
                /// </summary>
                /// <param name="provider">认证信息提供对象</param>
                /// <returns>pipelineClient 构造器</returns>
                public Builder CredentialsProvider(CredentialsProvider provider)
                {
                    pipelineClient.credentialsProvider = provider;
                    return this;
                }

                /// <summary>
                /// 设置请求环境参数
                /// </summary>
                /// <param name="environment">环境参数信息</param>
                /// <returns>pipelineClient 构造器</returns>
                public Builder Environment(SDKEnvironment environment)
                {
                    pipelineClient.environment = environment;
                    return this;
                }

                /// <summary>
                /// http 请求配置信息
                /// </summary>
                /// <param name="config">http 请求配置信息</param>
                /// <returns>pipelineClient 构造器</returns>
                public Builder HttpRequestConfig(HttpRequestConfig config)
                {
                    pipelineClient.httpRequestConfig = config;
                    return this;
                }
            }
    }
}
